package com.ctcemti.mdm.project.sys.service.impl;

import com.ctcemti.mdm.project.sys.dao.RelDisciplinesMethodsMapper;
import com.ctcemti.mdm.project.sys.entity.RelDisciplinesMethods;
import com.ctcemti.mdm.project.sys.service.IRelDisciplinesMethodsService;
import com.ctcemti.mdm.project.sys.service.IRelDisciplinesMethodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class RelDisciplinesMethodsServiceImpl implements IRelDisciplinesMethodsService {

    @Autowired
    private RelDisciplinesMethodsMapper relDisciplinesMethodsMapper;

    @Transactional
    @Override
    public int insertSelective(RelDisciplinesMethods record) {
        int flag = 0;
        String[] methodid = record.getMeithodIds().split(",");
        for (int i=0;i<methodid.length;i++){
            record.setMeithodId(Integer.valueOf(methodid[i]));
            List<RelDisciplinesMethods> list = relDisciplinesMethodsMapper.select(record);
            if(list.size()>0){
                continue;
            }
            flag = relDisciplinesMethodsMapper.insertSelective(record);
        }
        return flag;
    }
}
